/**
 * 
 */
package com.nari.basic.utils.struts2tags;

import java.util.Comparator;

import com.nari.basic.model.IMenu;

/**
 * 自定义Struts2标签sort列表比较器
 * @author Xiaopeng
 * @date 2013-8-4
 */
public class MenuComparator implements Comparator<IMenu> {

	public int compare(IMenu menu1, IMenu menu2) {
		if(menu1.getOrderID() == null) menu1.setOrderID(0);
		if(menu2.getOrderID() == null) menu2.setOrderID(0);
		if(menu1.getOrderID()-menu2.getOrderID() != 0) {
			return menu1.getOrderID()-menu2.getOrderID();
		} else {
			return new Long(menu2.getCreateTime().getTime() - menu1.getCreateTime().getTime()).intValue();
		}
	}

}
